"""tensor裁剪，数据约束"""

import torch


def test_clamp():
    print("==== clamp ====")
    a = torch.rand(2, 2) * 10
    print("torch.rand(2, 2) * 10")
    print(a)
    print()

    a = a.clamp(2, 5)
    print("a.clamp(2, 5) ==> 2<=x<=5")
    print(a)
    print()


if __name__ == '__main__':
    test_clamp()
